﻿using System;

namespace System.Data
{
    /// <summary>
    /// 数据库数据结构的自定义特性
    /// </summary>
    [AttributeUsage(AttributeTargets.Field|AttributeTargets.Property,AllowMultiple = true,Inherited =true)]
    public class DbSettingAttribute : Attribute
    {
        /// <summary>
        /// 是否是主键
        /// </summary>
        public bool IsPrimary = false;

        /// <summary>
        /// 是否是外键
        /// <para>开启后需要设置 ForeignReference 关联的表名和列 </para>
        /// </summary>
        public bool IsForeign = false;

        /// <summary>
        /// 是否不能为空
        /// </summary>
        public bool IsNotNull = false;

        /// <summary>
        /// 是否使用声明的类型
        /// <para>默认不使用</para>
        /// </summary>
        public bool IsUseType = false;

        /// <summary>
        /// 默认值
        /// </summary>
        public object DefaultValue = null;

        /// <summary>
        /// 在数据库中声明的类型
        /// <para>如果声明了具体类型，一定要开启 IsUseType</para>
        /// </summary>
        public string dbType = "VARCHAR(255)";

        /// <summary>
        /// 外键关联的表名
        /// <para>需要开启 IsForeign 才会生效</para>
        /// </summary>
        public string ForeignReference = "RefTable (ColumnName)";
    }
}
